Repository navigation
Conversation
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
694b6ea to
43ccf7d
Compare
Local pipeline review — ✅ PASSschema: doris-repo-review/v1
status: PASS
pr: apache/doris#70363
commit: 43ccf7d0a4e7df3e9dc8d566dfb209556decfedb
base: 3f4002e778bd4bdac135b349f349e5ed4d7a5093
reviewed_at: 2026-11-07T13:09+08:00
reviewer: eldenmoon
model: gpt-6-astra
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 0}
rounds: 1
converged: trueNotes for maintainers
Reviewed locally with the |
41d6057 to
ce1ffe3
Compare
|
Update in this branch:
Local status: the new case and the existing |
|
run buildall |
BE UT Coverage ReportIncrement line coverage Increment coverage report
|
FE UT Coverage ReportIncrement line coverage |
|
run feut |
FE UT Coverage ReportIncrement line coverage |
|
run cloud_p0 |
|
run external |
|
run cloud_p0 |
|
run external |
|
run cloud_p0 |
|
run external |
|
run cloud_p0 |
|
run external |
### What problem does this PR solve? Related PR: apache#70359 Problem Summary: Legacy Variant casts may return SQL NULL for NOT NULL inputs, but their non-nullable FE declaration allowed null-safe predicates to fold to FALSE and removed COALESCE/NVL fallbacks. Apply the shared nullable rule to both Variant execution representations, as in apache#70359. ### Release note Fix NULL predicate and conditional-function results, and nullable column type mismatches, for casts from NOT NULL Variant values. ### Check List (For Author) - Test: Unit Test - 59 focused FE unit tests passed; pre-fix CAST and optimizer tests failed as expected. SQL regression validation is recorded in the test commit and PR. - Behavior changed: Yes. Correct nullable declarations prevent invalid rewrites or result type mismatches; BE conversion semantics are unchanged. - Does this need documentation: No
…lization ### What problem does this PR solve? Related PR: apache#70359 Problem Summary: after fixing Variant CAST nullable metadata, a filter such as CAST(v AS INT) IS NULL can still lose rows. Scan normalization strips the Variant cast and substitutes a NullPredicate on the source column, although the cast can introduce SQL NULL for a non-NULL stored value. Keep null tests on casts as expressions using the existing pushdown rejection path. IS NOT NULL uses the same path. CAST conversion semantics and storage are unchanged. ### Release note Fix missing or extra rows from NULL filters over Variant casts. ### Check List (For Author) - Test: ASAN build.sh --be; focused SQL regression generation passed - Behavior changed: Yes. Evaluate the cast's NULL result before filtering. - Does this need documentation: No
…acks ### What problem does this PR solve? Related PR: apache#70359 Problem Summary: cover legacy Variant-to-non-Variant CAST nullable inference, optimizer preservation of IS NULL / <=> NULL and COALESCE / NVL, and scan filtering on CAST results. Include nullable inputs, incompatible values, identity casts, aliases, and all-Variant-null roots. Limit the representation- specific SQL golden to legacy Variant execution. The baseline FE tests fail on nullable inference and simplification; the baseline SQL fails with a nullable mismatch, and the FE-only fix still loses rows in scan filters. ### Release note None ### Check List (For Author) - Test: 59 FE tests passed; test_variant_cast_nullable and test_variant_cast passed with ASAN BE (2 suites); golden generated by run-regression-test.sh - Behavior changed: No - Does this need documentation: No
Make the scan normalization guard check the cast source type explicitly (Variant) instead of skipping every cast, and add the `variant_p0/test_variant_cast_isnull_pushdown` regression: `CAST(v AS INT) IS NULL`, `IS NOT NULL` and `<=> NULL` over a `VARIANT NOT NULL` column. Without the guard the `IS NULL` / `<=> NULL` filters return no rows, because the scan rewrites the null test on the cast into `v IS NULL` and drops the non-NULL rows whose cast result is NULL.
ce1ffe3 to
dde6111
Compare
|
run buildall |
|
run compile |
|
run beut |
|
run compile |
|
run external |
|
run cloud_p0 |
|
run p0 |
|
run external |
|
run beut |
|
run feut |
|
run external |
7 similar comments
|
run external |
|
run external |
|
run external |
|
run external |
|
run external |
|
run external |
|
run external |
What problem does this PR solve?
Cherry-pick of #70359 (adapted for
branch-4.1) plus the BE scan fix proposed on master in #70365.Related PR: #70359, #70365
Problem Summary: backport the Variant-to-non-Variant nullable fix to branch-4.1 and retain the resulting null tests during scan normalization. A NOT NULL Variant column can contain Variant nulls or values that cannot be converted to a scalar. The existing BE CAST can return SQL NULL, but
Cast.castNullableonly accounted for Variant V2 and legacy casts to JSON.This causes both wrong optimizer rewrites and execution contract failures:
<=> NULLbecomes FALSE, COALESCE/NVL lose their fallback, and direct CAST queries can fail with a declared non-nullable / actual nullable mismatch.End-to-end validation exposed a second issue: after correcting FE metadata, scan normalization still replaced
CAST(v AS INT) IS NULLwith a null test on the source Variant column. This loses NULLs introduced by conversion; IS NOT NULL can retain the wrong rows.Fix
Cast.castNullablerule to declare Variant-to-non-Variant casts nullable for both representations. Identity casts retain input nullability; no optimizer-specific nullable rule is added.Validation
<=> NULL, and removal of conditional fallbacks. SQL fails with a nullable column mismatch. With the FE fix alone, scan filters still incorrectly return no rows; the captured projection results identify the rows that should survive.build.sh.Compatibility and performance
BE CAST conversion semantics, storage formats, and Thrift definitions are unchanged. The fix corrects metadata, optimizer simplification, and filtering against the existing conversion result. Existing legacy Variant conversion quirks are preserved by the golden tests.
The FE change adds no per-row conversion work. Unsafe NULL-predicate pushdown over a Variant cast is replaced by expression evaluation, which may scan/evaluate more rows for those predicates; ordinary source-column NULL pushdown is unchanged. No performance benchmark is claimed. No new public API or dependency is added.
Release note
Fix incorrect NULL predicates, conditional-function simplification, and nullable result type mismatches when casting Variant values to non-Variant types with legacy Variant execution.
Check List (For Author)
Update: explicit Variant check + NOT NULL-column regression
CAST_EXPR. Behaviour is unchanged for the reachable shape (only Variant casts passis_valid_push_down_cast), but the condition is self-documenting and no longer relies on that implicit precondition.variant_p0/test_variant_cast_isnull_pushdown:CAST(v AS INT) IS NULL,IS NOT NULLand<=> NULLon aVARIANT NOT NULLcolumn. The existingis_null_filteronly coveredCAST(v AS STRING), where every row is non-null, so it could not catch a removed guard. The golden was generated by the regression runner. Without the guard the new test returns no rows forIS NULL/<=> NULL.